package com.buddy.jni.demo05;

public class JNIPrimitiveArray {
    static{
        System.loadLibrary("jni_primitive_array");
    }

    /**
     * Declare a native method sumAndAverage() that receives an int[] and
     * return a double[2] array with [0] as sum and [1] as average
     * @param numbers
     * @return
     */
    private native double[] sumAndAverage(int[] numbers);

    public static void main(String[] args){
        int[] numbers = {22, 33, 33};
        double[] results = new JNIPrimitiveArray().sumAndAverage(numbers);
        System.out.println("In Java, the sum is " + results[0]);
        System.out.println("In Java, the average is " + results[1]);
    }
}
